<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">
       <h2>总价格：：{{totalPrice}}</h2>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                 message:'我是你爹!' ,
                 books: [
                    { id: 1, name: "Unix编程艺术", price: 100 },
                    { id: 2, name: "代码大全", price: 110 },
                    { id: 3, name: "Java从入门到入土", price: 120 },
                    { id: 4, name: "Linux操作系统", price: 130 }
                ]
            },
            methods: {},
            computed:{
                totalPrice:function(){
                    let totalPrice=0;
                    for(let i=0;i<this.books.length;i++){
                        totalPrice+=this.books[i].price;
                    }
                    return totalPrice;
                }
            }
        });
    </script>
</body>

</html>